<template>
  <div>
 <el-table
    :data="$store.getters['role/getRole']"
    border
    style="width: 100%">
    <el-table-column
      prop="id"
      label="角色编号"
      width="180">
    </el-table-column>
    <el-table-column
      prop="rolename"
      label="角色名称"
      width="180">
    </el-table-column>
    <el-table-column
      label="状态">
 <el-button plain size="mini" type="success">启用</el-button>

    </el-table-column>

  <el-table-column
      label="操作">
       <template slot-scope="item">
        <div>

           <el-button plain  size="mini"  type="primary"  @click='edit(item.row.id)'>编辑</el-button>
 <el-button plain size="mini" type="danger" @click="expurgate(item.row.id)">删除</el-button>
        </div>
   </template>
    </el-table-column>

  </el-table>

  </div>
</template>

<script>
import { roleDelete } from '../../../api/api.js'
export default {
  data () {
    return {

    }
  },
  mounted () {
    this.$store.dispatch('role/getRolelist')
  },
  computed: {

  },
  methods: {
    edit (id) {
      this.$emit('edit', id)
    },
    expurgate (id) {
      // 删除
      console.log(111)
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        roleDelete({ id }).then(res => {
          if (res.code === 200) {
            this.$message.success(res.msg)
            this.$store.dispatch('role/getRolelist')
          } else {
            this.$message.error(res.msg)
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>

<style>

</style>
